package com.maibow.controller.app;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.maibow.controller.base.BaseController;
import com.maibow.entity.admin.DictionaryCatalog;
import com.maibow.entity.admin.Version;
import com.maibow.entity.app.Food;
import com.maibow.service.admin.VersionService;
import com.maibow.service.app.FoodService;
import com.maibow.service.members.MembersService;
import com.maibow.service.task.MeetTaskService;
import com.maibow.util.DateUtil;
import com.maibow.util.Logger;
import com.maibow.util.PageData;

/**
 * 
 * 脉博网络后台管理系统
 * 包名：com.maibow.controller.app
 * 文件名：FindFoodListController.java
 * 作者: 吴比(Wubi)
 * 时间：2015年4月11日-下午3:28:59
 * Copyright@ 2015湖南脉博网络科技有限公司-版权所有
 *
 */
@Controller
@RequestMapping(value = "/api")
public class FindFoodListController extends BaseController {

    protected Logger logger = Logger.getLogger(this.getClass());

    @Autowired
    @Qualifier("foodService")
    private FoodService foodService;

    @Resource(name = "membersService")
    private MembersService membersService;

    @Resource(name = "versionService")
    private VersionService versionService;

    @Resource(name = "meetTaskService")
    MeetTaskService meetTaskService;

    /** 根据餐菜的类别返回 该类别下的所有菜 */
    @RequestMapping("/findFoodList")
    public ModelAndView queryFoodList(@RequestParam("typeId") int typeId) {

        List<Food> list = foodService.getFoodListByType(typeId);
        ModelAndView modelView = new ModelAndView();
        Map<String, Object> modelMap = new HashMap<String, Object>();
        modelMap.put("FOOD_LIST", list);
        modelMap.put("TYPE_ID", typeId);
        modelView.addAllObjects(modelMap);
        return modelView;
    }

    /**
     * 
     * queryFoodList1(这里用一句话描述这个方法的作用)
     * (这里描述这个方法适用条件 – 可选)
     * 标记：@param typeId
     * 标记：@param request
     * 标记：@param response
     * 标记：@return
     * 返回值：ModelAndView
     * 作者：吴比(Wubi)
     * 
     * @exception
     * @since 1.0.0
     */
    // http://localhost:8088/maibow-manage/findFoodList1/1.json
    @RequestMapping("/findFoodList1/{typeId}")
    public ModelAndView queryFoodList1(@PathVariable int typeId, HttpServletRequest request, HttpServletResponse response) {
        List<Food> list = foodService.getFoodListByType(typeId);
        ModelAndView modelView = new ModelAndView();
        Map<String, Object> modelMap = new HashMap<String, Object>();
        modelMap.put("FOOD_LIST", list);
        modelMap.put("TYPE_ID", typeId);
        modelView.addAllObjects(modelMap);
        return modelView;
    }

    /**
     * 
     * getProductInfo(这里用一句话描述这个方法的作用)
     * (这里描述这个方法适用条件 – 可选)
     * 标记：@param cataId
     * 标记：@param request
     * 标记：@param response
     * 标记：@return
     * 标记：@throws Exception
     * 返回值：ModelAndView
     * 作者：吴比(Wubi)
     * 
     * @exception
     * @since 1.0.0
     */
    // localhost:8088/maibow-manage/api/info/00001.json
    @RequestMapping(value = { "/info/{cataId}" }, method = RequestMethod.GET)
    public ModelAndView getProductInfo(@PathVariable String cataId, HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        DictionaryCatalog dictionaryCatalog = new DictionaryCatalog();
        dictionaryCatalog.setCataid(1);
        map.put("cataId", cataId);
        map.put("dictionaryCatalog", dictionaryCatalog);
        ModelAndView mav = new ModelAndView("products/list", map);
        return mav;
    }

    @RequestMapping(value = { "/hongbao/{mid}" }, method = RequestMethod.GET)
    public ModelAndView processHongbao(@PathVariable String mid, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = this.getPageData();
        pageData.put("m_id", "1");
        pageData = membersService.findById(pageData); // 根据ID读取
        modelView.setViewName("hongbao/hongbao");
        modelView.addObject("pageData", pageData);
        return modelView;
    }

    @RequestMapping(value = { "/download" }, method = RequestMethod.GET)
    public ModelAndView processDownload1(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = this.getPageData();
        Version iphoneVersion = versionService.findIPHONEVersion(pageData);
        Version androidVersion = versionService.findANDROIDVersion(pageData);
        androidVersion.setUrl("http://www.hnczwl.cn:8088/maibow-global/" + androidVersion.getUrl());
        if (null != androidVersion.getUrl2() && !"".equals(androidVersion.getUrl2()) && !"''".equals(androidVersion.getUrl2())) {
            androidVersion.setUrl(androidVersion.getUrl2());
        }

        modelView.setViewName("download/download1");
        modelView.addObject("iphoneVersion", iphoneVersion);
        modelView.addObject("androidVersion", androidVersion);
        return modelView;
    }

    @RequestMapping(value = { "/download1" }, method = RequestMethod.GET)
    public ModelAndView processDownload2(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = this.getPageData();
        Version iphoneVersion = versionService.findIPHONEVersion(pageData);
        Version androidVersion = versionService.findANDROIDVersion(pageData);
        androidVersion.setUrl("http://www.hnczwl.cn:8088/maibow-global/" + androidVersion.getUrl());
        if (null != androidVersion.getUrl2() && !"".equals(androidVersion.getUrl2()) && !"''".equals(androidVersion.getUrl2())) {
            androidVersion.setUrl(androidVersion.getUrl2());
        }

        modelView.setViewName("download/download2");
        modelView.addObject("iphoneVersion", iphoneVersion);
        modelView.addObject("androidVersion", androidVersion);
        return modelView;
    }

    @RequestMapping(value = { "/download/{channel}" }, method = RequestMethod.GET)
    public ModelAndView processDownload(@PathVariable String channel, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = this.getPageData();
        Version iphoneVersion = versionService.findIPHONEVersion(pageData);
        Version androidVersion = versionService.findANDROIDVersion(pageData);
        androidVersion.setUrl("http://www.hnczwl.cn:8088/maibow-global/" + androidVersion.getUrl());
        if (null != androidVersion.getUrl2() && !"".equals(androidVersion.getUrl2()) && !"''".equals(androidVersion.getUrl2())) {
            androidVersion.setUrl(androidVersion.getUrl2());
        }

        modelView.setViewName("download/download");
        modelView.addObject("iphoneVersion", iphoneVersion);
        modelView.addObject("androidVersion", androidVersion);
        modelView.addObject("channel", channel);
        return modelView;
    }

    @RequestMapping(value = { "/statisticDownloadQuantity/{channel}/{type}" }, method = RequestMethod.POST)
    @ResponseBody
    public ModelAndView statisticDownloadQuantity(@PathVariable String channel, @PathVariable String type, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        // PageData pageData = this.getPageData();
        // String channel =
        // pageData.get("channel").toString();
        // String type =
        // pageData.get("type").toString();
        logger.debug("channel===================== " + channel + " type========================" + type);
        PageData paramPageData = new PageData();
        paramPageData.put("channel", channel);
        paramPageData.put("type", Integer.valueOf(type));

        Date currentDate = new Date();
        String current_date = DateUtil.getCurrentDate(currentDate);
        paramPageData.put("current_date", current_date);
        PageData pageData = versionService.queryAppDownloadQuantity(paramPageData);
        if (Integer.valueOf(pageData.get("quantity").toString()) == 0) {
            // 点击安卓下载
            if (type.equals("1") && channel.equals("1")) {
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 苹果端
                paramPageData.put("type", 2);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }

            if (type.equals("1") && channel.equals("2")) {
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 苹果端
                paramPageData.put("type", 2);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }

            if (type.equals("1") && channel.equals("3")) {
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 苹果端
                paramPageData.put("type", 2);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 2);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }

            // 点击苹果下载
            if (type.equals("2") && channel.equals("1")) {
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 安卓端
                paramPageData.put("type", 1);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }

            if (type.equals("2") && channel.equals("2")) {
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 安卓端
                paramPageData.put("type", 1);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }

            if (type.equals("2") && channel.equals("3")) {
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 1);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                // 安卓端
                paramPageData.put("type", 1);
                paramPageData.put("channel", 1);
                paramPageData.put("channel_name", "桌台二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 2);
                paramPageData.put("channel_name", "吧台灯二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);

                paramPageData.put("type", 1);
                paramPageData.put("channel", 3);
                paramPageData.put("channel_name", "海报二维码");
                paramPageData.put("download_times", 0);
                versionService.insertAppDownloadQuantity(paramPageData);
            }
        } else {
            versionService.statisticDownloadQuantity(paramPageData);
        }

        modelView.addObject("success");
        return modelView;
    }

    @RequestMapping(value = { "/statisticScanQuan" }, method = RequestMethod.POST)
    @ResponseBody
    public ModelAndView statisticScanQuan(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = new PageData();
        pageData = this.getPageData();
        String code = pageData.get("code").toString();
        logger.debug("code===================== " + code);
        String[] codes = code.split("_");
        String organ_id = codes[0];
        String table_no = codes[1];

        PageData paramPageData = new PageData();
        paramPageData.put("organ_id", Integer.valueOf(organ_id));
        paramPageData.put("table_no", table_no);
        Date currentDate = new Date();
        String current_date = DateUtil.getCurrentDate(currentDate);
        paramPageData.put("current_date", current_date);
        paramPageData.put("scan_times", 1);
        PageData resultpageData = versionService.queryAppScanQuantity(paramPageData);
        if (Integer.valueOf(resultpageData.get("quantity").toString()) == 0) {
            versionService.insertAppScanQuantity(paramPageData);
        } else {
            versionService.statisticScanQuantity(paramPageData);
        }
        // 112_F001

        modelView.addObject("success");
        return modelView;
    }

    /**
     * 游戏结果
     * processRankings(这里用一句话描述这个方法的作用)
     * (这里描述这个方法适用条件 – 可选)
     * 标记：@param request
     * 标记：@param response
     * 标记：@return
     * 标记：@throws Exception
     * 返回值：ModelAndView
     * 作者：吴比(Wubi)
     * 
     * @exception
     * @since 1.0.0
     */
    @RequestMapping(value = { "/ranking/{mid}/{pid}" }, method = RequestMethod.GET)
    public ModelAndView processRankings(@PathVariable String mid, @PathVariable String pid, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        PageData pageData = this.getPageData();
        pageData.put("p_id", Integer.valueOf(pid));
        pageData.put("m_id", mid);
        List<PageData> rankingsList = meetTaskService.queryAllGiftPackageDistributionList(pageData);
        List<PageData> theFirstThreeList = new ArrayList();
        List<PageData> theLastThreeList = new ArrayList();
        PageData ownerPageData = new PageData();
        PageData giftPackagePd = meetTaskService.queryGiftPackageById(pageData);
        String invalid_time = giftPackagePd.get("invalid_time").toString();
        // invalid_time = "2015-08-23 16:31:00";
        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date mydate = myFormatter.parse(invalid_time);

        Calendar cal = Calendar.getInstance();
        cal.setTime(mydate);
        int year = cal.get(Calendar.YEAR);// 获取年份
        int month = cal.get(Calendar.MONTH);// 获取月份
        int day = cal.get(Calendar.DATE);// 获取日
        int hour = cal.get(Calendar.HOUR_OF_DAY);// 小时
        int minute = cal.get(Calendar.MINUTE);// 分
        int second = cal.get(Calendar.SECOND);// 秒

        String yearstr = String.valueOf(year);
        String monthstr = String.valueOf(month);
        String daystr = String.valueOf(day);
        String hoursstr = String.valueOf(hour);
        String minutestr = String.valueOf(minute);
        String secondsstr = String.valueOf(second);
        pageData.put("year", yearstr);
        pageData.put("month", monthstr);
        pageData.put("day", daystr);
        pageData.put("hours", hoursstr);
        pageData.put("minute", minutestr);
        pageData.put("seconds", secondsstr);

        pageData.put("award_amount", giftPackagePd.get("quantity"));
        pageData.put("rank_valid_time", DateUtil.formatTime(invalid_time));
        cal.add(Calendar.DATE, 1);
        String get_award_valid_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
        pageData.put("get_award_valid_time", DateUtil.formatTime(get_award_valid_time));

        if (rankingsList == null || rankingsList.size() == 0) {
            PageData paramPageData = new PageData();
            paramPageData.put("m_id", mid);
            PageData memberPageData = membersService.findById(paramPageData); // 根据ID读取
            if (null != memberPageData) {
                ownerPageData.put("head_icon", memberPageData.get("head_icon"));
            }
            modelView.setViewName("hongbao/index");
            modelView.addObject("ownerPageData", ownerPageData);
            modelView.addObject("theFirstThreeList", theFirstThreeList);
            modelView.addObject("theLastThreeList", theLastThreeList);
            modelView.addObject("pageData", pageData);
            return modelView;
        }

        for (int i = 0; i < rankingsList.size(); i++) {
            PageData rankingPageData = rankingsList.get(i);
            processRankingsWithMember(theFirstThreeList, rankingPageData, ownerPageData, mid, i);
        }

        /*
         * for (int i = 0; i <
         * rankingsList.size(); i++) {
         * PageData rankingPageData =
         * rankingsList.get(i);
         * processRankingsWithMember(theFirstThreeList
         * , rankingPageData, ownerPageData, mid,
         * i);
         * }
         * for (int i = 0; i <
         * rankingsList.size(); i++) {
         * PageData rankingPageData =
         * rankingsList.get(i);
         * processRankingsWithMember(theFirstThreeList
         * , rankingPageData, ownerPageData, mid,
         * i);
         * }
         */

        for (int i = 3; i < rankingsList.size(); i++) {
            PageData rankingPageData = rankingsList.get(i);
            processRankingsWithMember(theLastThreeList, rankingPageData, ownerPageData, mid, i);
        }

        /*
         * for (int i = 0; i <
         * rankingsList.size(); i++) {
         * PageData rankingPageData =
         * rankingsList.get(i);
         * processRankingsWithMember(theLastThreeList
         * , rankingPageData, ownerPageData, mid,
         * i);
         * }for (int i = 0; i <
         * rankingsList.size(); i++) {
         * PageData rankingPageData =
         * rankingsList.get(i);
         * processRankingsWithMember(theLastThreeList
         * , rankingPageData, ownerPageData, mid,
         * i);
         * }for (int i = 0; i <
         * rankingsList.size(); i++) {
         * PageData rankingPageData =
         * rankingsList.get(i);
         * processRankingsWithMember(theLastThreeList
         * , rankingPageData, ownerPageData, mid,
         * i);
         * }
         */

        if (mydate.getTime() > new Date().getTime()) {
            theFirstThreeList.removeAll(theFirstThreeList);
            theLastThreeList.removeAll(theLastThreeList);
            ownerPageData.remove("owner_rankings");
        }

        modelView.setViewName("hongbao/index");
        modelView.addObject("ownerPageData", ownerPageData);
        modelView.addObject("theFirstThreeList", theFirstThreeList);
        modelView.addObject("theLastThreeList", theLastThreeList);
        modelView.addObject("pageData", pageData);
        return modelView;
    }

    /**
     * 
     * processRankingsWithMember(这里用一句话描述这个方法的作用)
     * (这里描述这个方法适用条件 – 可选)
     * 标记：@param rankingsList
     * 标记：@param theFirstThreeList
     * 标记：@param rankingPageData
     * 标记：@param mid
     * 返回值：void
     * 作者：吴比(Wubi)
     * 
     * @throws Exception
     * 
     * @exception
     * @since 1.0.0
     */
    private void processRankingsWithMember(List<PageData> theResultList, PageData rankingPageData, PageData ownerPageData, String mid, int index) throws Exception {
        PageData paramPageData = new PageData();
        if (null != rankingPageData.get("receive_m_id")) {
            paramPageData.put("m_id", rankingPageData.get("receive_m_id").toString());
            PageData memberPageData = membersService.findById(paramPageData); // 根据ID读取
            rankingPageData.put("username", memberPageData.get("username"));
            rankingPageData.put("gender", memberPageData.get("gender"));
            rankingPageData.put("head_icon", memberPageData.get("head_icon"));
            rankingPageData.put("member_rate", memberPageData.get("member_rate"));

            // rankingPageData.put("age", 25);
            // rankingPageData.put("constellation",
            // "狮子座");
            // rankingPageData.put("member_rate",
            // 2);

            if (memberPageData.get("birth") != null) {
                String birthday = memberPageData.get("birth").toString();
                SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                Date mydate = myFormatter.parse(birthday);
                long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000) + 1;
                String year = new java.text.DecimalFormat("#.00").format(day / 365f);
                rankingPageData.put("age", year);
            }

            // rankingPageData.put("quantity",
            // "1000");
            if (rankingPageData.get("quantity") == null) {
                rankingPageData.put("quantity", "0");
            }

            if (rankingPageData.get("receive_m_id").toString().equals(mid)) {
                ownerPageData.put("owner_rankings", index + 1);
                ownerPageData.putAll(rankingPageData);
                // ownerPageData.remove("quantity");
            }
        }
        theResultList.add(rankingPageData);
    }

    /**
     * 
     * print(这里用一句话描述这个方法的作用)
     * (这里描述这个方法适用条件 – 可选)
     * 标记：@param request
     * 标记：@param response
     * 标记：@return
     * 标记：@throws Exception
     * 返回值：ModelAndView
     * 作者：吴比(Wubi)
     * 
     * @exception
     * @since 1.0.0
     */
    @RequestMapping(value = { "/print" }, method = RequestMethod.GET)
    public ModelAndView print(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView modelView = this.getModelAndView();
        modelView.setViewName("testprint/test");
        return modelView;
    }
}